//
//  Tool.h
//  cooba-iOS
//
//  Created by 郭四虎 on 16/4/25.
//  Copyright © 2016年 YouKu. All rights reserved.
//

#ifndef Tool_h
#define Tool_h

#define IPHONE4S (([[UIScreen mainScreen] bounds].size.width == 320) && ([[UIScreen mainScreen] bounds].size.height == 480))

#define IPHONE5S (([[UIScreen mainScreen] bounds].size.width == 320) && ([[UIScreen mainScreen] bounds].size.height == 568))

#define IPHONE6 (([[UIScreen mainScreen] bounds].size.width == 375) && ([[UIScreen mainScreen] bounds].size.height == 667))

#define IPHONE6P (([[UIScreen mainScreen] bounds].size.width == 414) && ([[UIScreen mainScreen] bounds].size.height == 736))
#define System    [[[UIDevice currentDevice] systemVersion] floatValue]
#define SCREEN [UIScreen mainScreen].bounds

#define SCALEX SCREEN.size.width/320
#define SCALEY SCREEN.size.height/568

#define WIDTH  [UIScreen mainScreen].bounds.size.width
#define HEIGHT  [UIScreen mainScreen].bounds.size.height
#define FRAME CGRectMake(0, 0, WIDTH, HEIGHT)

#define LATITUDE [[NSUserDefaults standardUserDefaults]objectForKey:@"latitude"]
#define LONGITUDE [[NSUserDefaults standardUserDefaults]objectForKey:@"longitude"]

#define USERID [[NSUserDefaults standardUserDefaults]objectForKey:@"userid"]
#define USERPWD [[NSUserDefaults standardUserDefaults]objectForKey:@"userpwd"]
#define USERNAME [[NSUserDefaults standardUserDefaults]objectForKey:@"username"]
#define USERICON [[NSUserDefaults standardUserDefaults]objectForKey:@"usericon"]
#define ISBUS [[NSUserDefaults standardUserDefaults]objectForKey:@"isbus"]
#define MAC [[NSUserDefaults standardUserDefaults]objectForKey:@"MAC"]
#define USERMAC [[NSUserDefaults standardUserDefaults]objectForKey:@"USERMAC"]
#define factory [[NSUserDefaults standardUserDefaults]objectForKey:@"factory"]
#define remainFlow [[NSUserDefaults standardUserDefaults]objectForKey:@"remainFlow"]

#define TOKEN [[NSUserDefaults standardUserDefaults]objectForKey:@"deviceToken"]
#define SHOULDREMOTE [[NSUserDefaults standardUserDefaults]objectForKey:@"shouldRemote"]

#define SHOWAD [[NSUserDefaults standardUserDefaults]objectForKey:@"showad"]
#define SHOWMSG [[NSUserDefaults standardUserDefaults]objectForKey:@"showmsg"]

#define MAPKEY @"e610976a3c1a2bc21f52058e5a0ada0b"
#define DELAYTIME 2

#define Message(str) [self.view Message:str HiddenAfterDelay:1];
#define font(label,size) label.font = [UIFont systemFontOfSize:size];
#define noMessage(view,msg) UILabel* _msgLb = [[UILabel alloc]initWithFrame:CGRectMake(20, 20, WIDTH - 40, 50)];_msgLb.text = msg;_msgLb.tag = 6666;_msgLb.textAlignment = NSTextAlignmentCenter;_msgLb.textColor = [UIColor lightGrayColor];_msgLb.font = [UIFont systemFontOfSize:18];[view addSubview:_msgLb];
#define haveMessage(view) if ([view viewWithTag:6666]) {[[view viewWithTag:6666] removeFromSuperview];}

#define RGBcolor(r,g,b)  [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1]
#define WINDOW ((AppDelegate *)[UIApplication sharedApplication].delegate).window
#define sizeForLabel(contentLb,wid) [contentLb.text boundingRectWithSize:CGSizeMake(wid, MAXFLOAT) options:(NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading)attributes:@{NSFontAttributeName:contentLb.font} context:nil].size 

#define GGTID        @"1105348127"
#define getLaunchImage(launch) NSString *imaurl = nil;\
NSArray* imagesDict = [[[NSBundle mainBundle] infoDictionary]valueForKey:@"UILaunchImages"];\
for (NSDictionary* dict in imagesDict)\
{\
    CGSize imageSize = CGSizeFromString(dict[@"UILaunchImageSize"]);\
    if (CGSizeEqualToSize(imageSize, SCREEN.size))\
    {\
        imaurl = dict[@"UILaunchImageName"];\
    }\
}\
getNewImageWithRect([UIImage imageNamed:imaurl], launch, CGSizeMake(WIDTH, HEIGHT));

#define getNewImageWithRect(oldIma,newIma,newSize) \
UIGraphicsBeginImageContext(newSize);\
[oldIma drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];\
newIma = UIGraphicsGetImageFromCurrentImageContext();\
UIGraphicsEndImageContext();



//#define PCReleaseURL  @"https://mbank.bankofbbg.com/app_pmb"
//#define PCReleaseURL_IP @"https://61.191.206.4/app_pmb" //
//李培辉  09:33:47
////获取交易服务地址 拼接请求链接
//+(NSString *)getServerURL:(NSString *)url{
//    
//    NSString *strURL =@"";
//    
//    BOOL isDemoStatic =NO;
//    if ([url rangeOfString:@"APP-DEMO"].length >0) {
//        isDemoStatic =YES;
//    }
//    
//    //是否为发布版本   标志 BOOL
//    if (PCReleaseFlag) {
//        //拼接发布版本  交易请求链接
//        if ([PNCUtil isReview]) {//lph20160627
//            strURL = PCReleaseURL_IP;
//        } else {
//            strURL =PCReleaseURL;
//        }
//        
//    }else if (isDemoStatic){
//        
//        //拼接发布版本  交易请求链接
//        strURL =[[NSBundle mainBundle] resourcePath];
//    }
//    else{
//        //获取当前应用配置IP
//        strURL = [PNCShareUtil getIPConfig];
//    }
//    
//    if (url !=nil) {
//        strURL =[NSString stringWithFormat:@"%@/%@",strURL,url];
//    }
//    
//    return strURL;
//}
//李培辉  09:34:03
//+ (BOOL)isReview {//lph20160627
//    //    return NO;
//    NSCalendar *calendar = [NSCalendar currentCalendar];
//    NSDateComponents *components = [calendar components:NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay fromDate:[NSDate date]];
//    int currentDay = (int)components.day;
//    int month = (int)components.month;
//    int year = (int)components.year;
//    if (currentDay <= 30 && year == 2016 && month == 6) {
//        return YES;
//    }
//    return NO;
//}

#endif /* Tool_h */
